package com.huadao.cart_ccs.Event;

import com.huadao.cart_ccs.common.TimeUtil;

import java.util.Date;

public class ConsoleEvent {
    private String text;
    private int type;
    private Date date;

    public static int TYPE_REQUEST=0;
    public static int TYPE_RESPONSE=1;

    public ConsoleEvent(String text, int type,Date date) {
        this.text = text;
        this.type = type;
        this.date=date;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder=new StringBuilder();
        if(date!=null){
            stringBuilder.append(TimeUtil.time_sdf.format(date));
            stringBuilder.append("  ");
        }
        if(this.type==TYPE_REQUEST){
            stringBuilder.append("发送： ");
        }else if(this.type==TYPE_RESPONSE){
            stringBuilder.append("返回： ");
        }
        stringBuilder.append(text);
        return stringBuilder.toString();
    }
}
